package com.huanzhidadi.logaspect.controller;

import com.huanzhidadi.logaspect.annotation.Log;
import com.huanzhidadi.logaspect.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "logMethod")
@RestController
@RequestMapping(value = "logMethod")
@Slf4j
public class LogMethodController {

    @ApiOperation(value = "日志记录")
    @RequestMapping(value = "/getLog", method = RequestMethod.POST)
    @Log(title = "方法级日志管理", businessType = BusinessType.OTHER)
    public Map<String, String> getLog(@RequestBody Map<String, String> paramMap) {
        Map<String, String> resultMap = new HashMap<>();
        resultMap.putAll(paramMap);
        resultMap.put("result", "ok");
        return resultMap;
    }

    @ApiOperation(value = "不进行日志记录")
    @RequestMapping(value = "/getNoLog", method = RequestMethod.POST)
    public Map<String, String> getNoLog(@RequestBody Map<String, String> paramMap) {
        Map<String, String> resultMap = new HashMap<>();
        resultMap.putAll(paramMap);
        resultMap.put("result", "ok");
        return resultMap;
    }

}
